package cn.itcast.n2.util;

import java.time.LocalDateTime;
import java.util.concurrent.TimeUnit;

public class Sleeper {
    public static void sleep(int i) {
        try {
            TimeUnit.SECONDS.sleep(i);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void sleep(double i) {
        try {
            TimeUnit.MILLISECONDS.sleep((int) (i * 1000));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void log(Object obj) {
        String name = Thread.currentThread().getName();
        String time = LocalDateTime.now().toString();
        System.out.println("thread[" + name + "] " + time + ": " + obj.toString());
    }
}
